import ala from 'ala'



/*
* wiki排序
* @array 树形数组
*/
export function wikiSort (array, newIndex, oldIndex) {
  if (!array) {
    array = []
  }
  // 排序
  array = ala.arrayDeepSort(array, newIndex, oldIndex)

  setTimeout(async () => {
    var response = sortSave(array)
    if (response) {
      ala.toast('保存成功')
    }
  }, 100)
  return array
}



function sortSave (array) {
  var saveArray = ala.arrayDeepAll(array)
  var response = ala.httpPost('Api/Wiki/Sort', saveArray).then(response => {
    return response
  })
  return response
}
